<template>
<div>
  <h2>添加业务</h2>

  <van-field v-model="form.name" label="添加业务" />
  <van-button type="info" @click="add">确认添加</van-button>

  <table>
    <tr>
      <td>业务</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in list">
      <td>{{i.name}}</td>
      <td>
        <van-button type="warning" @click="canshu(i.id)">参数配置</van-button>
      </td>
    </tr>
  </table>

</div>
</template>

<script>
export default {
  name: "day01_add",
  data(){
    return{
      form:{},
      list:[]
    }
  },
  methods:{
    add(){
      this.$axios.post('users/yewu',this.form)
      .then(i=>{
        if (i.data.code==200){
          alert('添加成功')
          this.show()
        }
      })
    },
    show(){
      this.$axios.get('users/yewu')
      .then(i=>{
        this.list = i.data.list
      })
    },
    canshu(id){
      this.$router.push({path:'/day01_canshu',query:{id:id}})
    }
  },
  mounted() {
    this.show()
  }
}
</script>

<style scoped>

</style>
